<script setup lang="ts">
import { ref } from 'vue'
import SonCom from './components/SonCom.vue'
const fname = ref('jack')
const fage = ref(18)

const fmoney = ref(10)
// 3. 写回调函数， 子组件触发后执行的逻辑 - 获取到子组件传过来的参数
const sonCall = (moneyNum: number) => {
  console.log('子组件触发事件' + moneyNum)
  fmoney.value = moneyNum
}
</script>

<template>
  <h2>我是父组件</h2>
  <!-- 4. 父组件文件中，给子组件注册事件 -->
  <SonCom :name="fname" :money="fmoney" @change-money="sonCall"></SonCom>
</template>

<style scoped>
h2 {
  border: 2px yellowgreen solid;
}
</style>
